'use strict';
var calculate_median = function(collection){
    let arr=collection.filter(function(element,index,collection){
        return index%2!==0;
    });
    let m=arr.length/2;
        for(let i=0;i<arr.length;i++){
        if(arr.length%2===0){
            return (arr[m]+arr[m-1])/2;  
        }else{
        return arr[m-1/2];
        }
    }
};
console.log(calculate_median([1, 2, 3, 4, 5, 6, 7, 8, 9]));
calculate_median( [1, 2, 3, 4, 5, 6, 7, 8, 9]);
module.exports = calculate_median;
